package com.zxx.pattern.iteratorPattern.iterator1;

/**
 * @author zxx on 2021/4/8
 */
public class AnimalIteratorTest {

    public static void main(String[] args) {
        AnimalCollection collection = new AnimalCollection();
        collection.addAnimal("小猫");
        collection.addAnimal("小狗");
        collection.addAnimal("小王");
        collection.addAnimal("小主");

        Iterator1 iterator1 = collection.iterator();
        while (iterator1.hasNext()) {
            System.out.println(iterator1.next());
        }
    }


}
